<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>在线证券分析系统用户注册页面</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
	 
	<link rel="stylesheet" type="text/css" href="./styles/finance.css">
	<script src="./javaScripts/jquery-1.5.1.min.js" type="text/javascript"></script>
	 <script type="text/javascript">
	     function validate(){
	     	if($("#userName").val()==""){
	     		alert("请输入用户名!");
	     		document.getElementById("userName").focus();
	     		return false;
	     	}else if($("#userName").val().length<4 || $("#userName").val().length>30){
	     		document.getElementById("userName").focus();
	     		alert("请输入正确的用户名![长度限制在2~15个汉字或4~30个字符(数字、字母、@、小数点、减号和下划线)]");
	     		return false;
	     	}
	     	if($("#password").val().trim()==""){
	     		alert("请输入密码!");
	     		$("#password").focus();
	     		return false;
	     	}else if($("#password").val().length<6 || $("#password").val().length>20){
	     		alert("请输入正确的密码!【6-20个字符（字母、数字），区分大小写】");
	     		$("#password").focus();
	     		return false;
	     	}
	     	if($("#rePassword").val().trim()==""){
	     		alert("请输入重复密码!");
	     		$("#rePassword").focus();
	     		return false;
	     	}else if($("#rePassword").val().length<6 || $("#rePassword").val().length>20){
	     		alert("请输入正确的重复密码!【6-20个字符（字母、数字），区分大小写】");
	     		$("#rePassword").focus();
	     		return false;
	     	}
	     	if($("#password").val() !=$("#rePassword").val()){
	     		alert("您输入的密码前后不一致，请重新输入!");
	     		$("#password").val("");
	     		$("#rePassword").val("");
	     		$("#password").focus();
	     		return false;
	     	}
	     	if($("#email").val().trim()==""){
	     		alert("请输入邮箱!");
	     		$("#email").focus();
	     		return false;
	     	}else{
	     		var email=$("#email").val();
	     		 var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
       			if(! reg.test(email)){
       				alert("请输入正确的邮箱!");
		     		$("#email").focus();
		     		return false;
       			}
	     	}
	     	if($("#validateCode").val().trim()==""){
	     		alert("请输入验证码!"); 
	     		return false;
	     	}
	     	return true;
	     }
	     function changeCodeImg(){
	         var img=document.getElementById("captcha");
	         img.src="<%=basePath%>"+"validateCode.action?timeStamp="+new Date().getTime();
	     }
	 </script>

	</head>

	<body>
	  <div id="mainContent" style="border: 1px solid #cccccc; height: auto !important; height: 400px; min-height: 400px;align:left;padding-top:5px;padding-buttom:2px;">
	     
	     <s:form action="register" method="post" theme="simple" namespace="/">
			<table align="center" style="valign:center;">
				<tr>
					<td  colspan="3">
						<span class="tip">
						<font color="red">
							<s:fielderror value="#attr.failure" id="failureTip"/></font>
						</span>
					</td>
				</tr>
				<tr>
					<td width="100px;" align="right">用户名：</td>
					<td align="left" >
						<s:textfield id="userName"  name="userName"></s:textfield>
					</td>
					<td align="left"><span class="tip">长度限制在2~15个汉字或4~30个字符(数字、字母、@、小数点、减号和下划线)。</span><span id="forName"></span>
					</td>
				</tr>
				<tr>
					<td align="right">密 码：</td>
					<td align="left">
						<s:password name="password" id="password"></s:password>
					</td>
					<td align="left">	<span class="tip">6-20个字符（字母、数字），区分大小写。</span><span id="forPWD"></span>
					</td>
				</tr>
				<tr>
					<td align="right">重复密码：</td>
					<td align="left">
						<s:password  name="rePassword" id="rePassword"></s:password>
					</td>
					<td align="left">	<span class="tip">6-20个字符（字母、数字），区分大小写。</span><span id="forPWD2"></span>
					</td>
				</tr>
				<tr>
					<td align="right">邮 箱：</td>
					<td align="left">
						<s:textfield name="email" id="email" value="%{attr.userDTO.email }"></s:textfield>
					</td>
					<td align="left">
					<s:if test="#attr.email ==null">
						<span class="tip">
						请填写有效邮箱，作为找回密码的唯一凭证。</span>
					</s:if>
					<s:else>
						<span class="tip">
						<font color="red">
							<s:fielderror value="#attr.email" id="emailTip"/></font>
						</span>
					</s:else>
					</td>
				</tr>
				<tr>
					<td align="right">验证码：</td>
					<td align="left">
						<s:textfield  name="validateCode" id="validateCode"></s:textfield>
					</td>
					<td align="left">
						<span id="forValidateCode"  class="error">
						<font color="red">
							<s:fielderror value="#attr.validateCodeError" id="validateCodeErrorTip"/></font>
						</span>
					</td>
				</tr>
				<tr>
					<td align="right">验证图片：</td>
					<td colspan="2" align="left"><span class="yam"> 
					<img id="captcha" src="validateCode.action"
							alt="看不清，换张图片" onclick="changeCodeImg();"> 
							<a href="javascript:changeCodeImg()">看不清，换张图片</a> </span>
					</td>
				</tr>
				<tr>
					<td align="right"><input id="agreement" type="checkbox" checked="checked"></td>
					<td colspan="2" align="left">我已经阅读并同意
						<a href="#" target="_blank">《在线证券分析系统用户注册协议》</a>
					</td>
				</tr>
				<tr>
					<td colspan="3"  class="tc" align="center">	
						<input type="submit" value="立即注册" class="btn2" onclick="return validate();">
					</td>
				</tr>
			
			</table>
		</s:form>
		</div>
	</body>
</html>
